export default[
    {
        path: '/',
        redirect: './home'
    },
    {
        path: '/home',
        component: ()=>import('@/pages/Home'),
        meta: {
            show: true
        }
    },
    {
        path: '/login',
        component: ()=>import('@/pages/Login'),
        meta: {
            show: false
        }
    },
    {
        path: '/search/:keyword?',
        name:'search',
        component: ()=>import('@/pages/Search'),
        meta: {
            show: true
        }
    },
    {
        path: '/register',
        component: ()=>import('@/pages/Register'),
        meta: {
            show: false
        }
    },
    {
        path: '/detail/:skuId',
        component: ()=>import('@/pages/Detail')
    },
    {
        path: '/addcartsuccess',
        name:'addcartsuccess',
        component: ()=>import('@/pages/AddCartSuccess')
    },
    {
        path: '/shopcart',
        name:'shopcart',
        component: ()=>import('@/pages/ShopCart')
    },
    {
        path:'/trade',
        component:()=>import('@/pages/Trade'),
        /* 只能从购物车界面, 才能跳转到交易界面 */
        beforeEnter(to,from,next){
            if(from.path == '/shopcart'){
                next()
            }else{
                next('/shopcart')
            }
        },
    },
    {
        path:'/pay',
        component:()=>import('@/pages/Pay'),
        /* 只能从交易界面, 才能跳转到支付界面 */
        beforeEnter(to,from,next){
            if(from.path == '/trade'){
                next()
            }else{
                next('/trade')
            }
        }
    },
    {
        path:'/paysuccess',
        component:()=>import('@/pages/PaySuccess'),
        /* 只有从支付界面, 才能跳转到支付成功的界面 */
        beforeEnter(to,from,next){
            if (from.path==='/pay') {
                next()
            }else{
                next('/pay')
            }
        },
    },
    {
        path:'/center',
        component:()=>import('@/pages/Center'),
        children:[
            {path:'/',redirect:'myorder'},
            {path:'myorder',component:import('@/pages/Center/myOrder')},
            {path:'groupbuy',component:import('@/pages/Center/groupOrder')}
        ]
    }
]